package fr.teuteuf.runstickmanrun.map.tile;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;

import fr.teuteuf.runstickmanrun.IRenderable;

public class Tile implements IRenderable {
	public static final int TILE_SIZE = 32;
	
	protected static Texture texture;
	protected TextureRegion textureRegion;
	protected Vector2 position;
	
	public Tile(int textureX, int textureY, int positionX, int positionY) {
		textureRegion = new TextureRegion(texture, textureX * TILE_SIZE, textureY * TILE_SIZE, TILE_SIZE, TILE_SIZE);
		position = new Vector2(positionX, positionY);
	}
	
	@Override
	public void render(SpriteBatch spriteBatch) {
		spriteBatch.draw(textureRegion, position.x, position.y);
	}
	
	public Vector2 getPosition() {
		return position;
	}
	
	public void destroy() {
	}
	
	public static void loadTexture() {
		texture = new Texture(Gdx.files.internal("tiles/grass_9.png"));
	}
	
	public static void dispose() {
		texture.dispose();
	}
}
